<html>
<head><meta charset="utf-8"><title>scalexm&#x27;s trait object thoughts · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html">scalexm&#x27;s trait object thoughts</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="154596770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154596770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154596770">(Jan 07 2019 at 20:01)</a>:</h4>
<blockquote>
<p>I’ll spawn another topic to explain myself later because I’m on my phone now</p>
</blockquote>
<p>Where have I <a href="https://en.wikiquote.org/wiki/Pierre_de_Fermat" target="_blank" title="https://en.wikiquote.org/wiki/Pierre_de_Fermat">heard that before</a>...</p>



<a name="154606104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154606104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154606104">(Jan 07 2019 at 22:17)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> so about trait objects</p>



<a name="154606117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154606117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154606117">(Jan 07 2019 at 22:17)</a>:</h4>
<p>my main concern is whether we want to have implied bounds on <code>dyn Trait</code> or not</p>



<a name="154606188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154606188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154606188">(Jan 07 2019 at 22:18)</a>:</h4>
<p>e.g., if you have:</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nb">Clone</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="c1">// do I want `Implemented(T: Clone)` to be implied or do I need to state it explicitly?</span>
<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">dyn</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="154606259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154606259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154606259">(Jan 07 2019 at 22:19)</a>:</h4>
<p>I believe having full implied bounds on <code>dyn Trait</code> seems natural but may be a difficult problem :)</p>



<a name="154606347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154606347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154606347">(Jan 07 2019 at 22:20)</a>:</h4>
<p>(at least a problem for which a margin could not contain the solution, cc <span class="user-mention" data-user-id="116155">@Jake Goulding</span> )</p>



<a name="154608960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154608960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154608960">(Jan 07 2019 at 23:06)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> well here is my proposal for full implied bounds on <code>dyn Trait</code>, I don't know if it is sound but I've not been able to break it yet (nor tried to actually prove it was sound)</p>



<a name="154608977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154608977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154608977">(Jan 07 2019 at 23:06)</a>:</h4>
<p>so the idea is that, when you have a trait object say <code>dyn Foo&lt;T&gt;</code>, the things we are afraid of are what we can deduce about <code>T</code></p>



<a name="154609066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154609066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154609066">(Jan 07 2019 at 23:08)</a>:</h4>
<p>the things we can deduce about <code>T</code> are basically:</p>
<ul>
<li>all the explicit bounds mentioning <code>T</code> that we can found on the <code>trait Foo&lt;T&gt; where ...</code> declaration</li>
<li>all the implicit outlive bounds on <code>T</code> than we can syntactically derive from outlive requirements on <code>Self</code> than can be found on the <code>trait Foo&lt;T&gt; where ...</code> declaration</li>
</ul>



<a name="154609206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154609206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154609206">(Jan 07 2019 at 23:10)</a>:</h4>
<p>any other bound not mentioning <code>T</code> (i.e. only mentioning <code>Self</code>) are harmless, because we cannot derive anything more about <code>T</code> from them</p>



<a name="154609224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154609224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154609224">(Jan 07 2019 at 23:11)</a>:</h4>
<p>so suppose a full trait declaration is given by:</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">WC1</span><span class="p">,</span><span class="w"> </span><span class="p">...,</span><span class="w"> </span><span class="n">WCn</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="154609332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154609332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154609332">(Jan 07 2019 at 23:13)</a>:</h4>
<p>I propose we define a specially marked symbol <code>SELF</code> and a new co-inductive predicate <code>Shallow(Type&lt;...&gt;: Foo&lt;...&gt;)</code> defined as:</p>
<div class="codehilite"><pre><span></span>forall&lt;...&gt; {
    Shallow(Type&lt;...&gt;: Foo&lt;...&gt;) :- MaybeShallow(WC1), ..., MaybeShallow(WCn)
}
</pre></div>


<p>where <code>MaybeShallow(WC)</code> is syntactic sugar for:</p>
<ul>
<li><code>WC</code> if <code>WC</code> is an outlive requirement or does not mention the <code>SELF</code> special symbol</li>
<li><code>Shallow(WC)</code> else</li>
</ul>
<p>So actually you can think of it as an infinite family of rules indexed by all the possible locations where <code>SELF</code> might appear</p>



<a name="154609477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154609477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154609477">(Jan 07 2019 at 23:16)</a>:</h4>
<p>then we define the following rules for the well-formedness of <code>dyn Foo&lt;T&gt;</code>:</p>
<div class="codehilite"><pre><span></span>WellFormed(dyn Foo&lt;T&gt;) :- Shallow(SELF: Foo&lt;T&gt;)
</pre></div>


<p>Eventually, if we manage to prove <code>Shallow(SELF: Foo&lt;T&gt;)</code>, the only thing we will have left are region constraints on <code>SELF</code>: we'll substitute <code>SELF</code> with <code>dyn Foo&lt;T&gt;</code> and prove that the region constraints are syntactically correct</p>
<p>We now define the following implied bound:</p>
<div class="codehilite"><pre><span></span>FromEnv(dyn Foo&lt;T&gt;: Foo&lt;T&gt;) :- FromEnv(dyn Foo&lt;T&gt;)
</pre></div>


<p>and the impl:</p>
<div class="codehilite"><pre><span></span><span class="c1">// Note that this impl is WF thanks to the above implied bound,</span>
<span class="c1">// because `dyn Foo&lt;T&gt;` is an input type of our impl hence we have</span>
<span class="c1">// `FromEnv(dyn Foo&lt;T&gt;)` in our environment.</span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">dyn</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>


<p>Note the asymmetry between the WF rule and the implied bound rule: in the former we only prove <code>Shallow(SELF: Foo&lt;T&gt;)</code> while in the latter we get the full set of bounds implied by <code>dyn Foo&lt;T&gt;: Foo&lt;T&gt;</code></p>



<a name="154609574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154609574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154609574">(Jan 07 2019 at 23:18)</a>:</h4>
<p>let's run this proposal through some examples</p>



<a name="154609671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154609671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154609671">(Jan 07 2019 at 23:20)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Animal</span><span class="o">&lt;</span><span class="n">X</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">Self</span>: <span class="nb">&#39;static</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="c1">// `Shallow(SELF: Animal&lt;?X&gt;) :- Outlives(SELF: &#39;static)`</span>

<span class="c1">// `WellFormed(dyn Animal&lt;&amp;&#39;a i32&gt;) :- Outlives(SELF: &#39;static)`</span>
<span class="c1">// Provable, but we have `Outlives(SELF: &#39;static)` as a region constraint.</span>
<span class="c1">// If we substitute `SELF` with `dyn Animal&lt;&amp;&#39;a i32&gt;`, this is yntactically wrong:</span>
<span class="c1">// `&amp;&#39;a i32` does not outlive `&#39;static`.</span>
</pre></div>



<a name="154609780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154609780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154609780">(Jan 07 2019 at 23:23)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Bar</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="c1">// `Shallow(SELF: Bar).`</span>

<span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span>: <span class="nc">Bar</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">T</span>: <span class="nb">Copy</span> <span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="c1">// `Shallow(SELF: Foo&lt;?T&gt;) :- Shallow(SELF: Bar), Implemented(?T: Copy)`</span>

<span class="c1">// ```</span>
<span class="c1">// WellFormed(dyn Foo&lt;String&gt;) :-</span>
<span class="c1">//     Shallow(SELF :- Foo&lt;String&gt;) :- Shallow(SELF: Bar), Implemented(String: Copy)</span>
<span class="c1">//                                             :- Implemented(String: Copy)</span>
<span class="c1">// ```</span>
<span class="c1">// Wrong.</span>
</pre></div>



<a name="154611208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154611208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154611208">(Jan 07 2019 at 23:52)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Baz</span><span class="o">&lt;</span><span class="n">X</span><span class="o">&gt;</span>: <span class="nc">where</span><span class="w"> </span><span class="n">Self</span>: <span class="nb">Copy</span> <span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="c1">// `Shallow(SELF: Baz&lt;?X&gt;).` // `Shallow(SELF: Copy)` is always true</span>
<span class="c1">// But we also have e.g.:</span>
<span class="c1">// `Shallow(?T: Baz&lt;SELF&gt;) :- Implemented(?T: Copy)`.</span>

<span class="k">trait</span><span class="w"> </span><span class="n">FooBaz</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">T</span>: <span class="nc">Baz</span><span class="o">&lt;</span><span class="n">Self</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="c1">// `Shallow(SELF: FooBaz&lt;?T&gt;) :- Shallow(?T: Baz&lt;SELF&gt;)`.</span>

<span class="c1">// ```</span>
<span class="c1">// WellFormed(dyn FooBaz&lt;String&gt;) :- Shallow(SELF: FooBaz&lt;String&gt;</span>
<span class="c1">//    :- Shallow(String: Baz&lt;SELF&gt;)</span>
<span class="c1">//    :- Implemented(String: Copy).</span>
<span class="c1">// ```</span>
<span class="c1">// Wrong.</span>
</pre></div>



<a name="154611490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154611490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154611490">(Jan 07 2019 at 23:58)</a>:</h4>
<p>Mmh ok so there is one thing that does not work 100% in this proposal, is that we can prove other bounds on <code>dyn Foo&lt;T&gt;</code> than just <code>Implemented(dyn Foo&lt;T&gt;: Foo&lt;T&gt;)</code> <strong>only</strong> if we have <code>FromEnv(dyn Foo&lt;T&gt;)</code> in our environment, because then we can use the implied bound rule</p>



<a name="154611512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154611512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154611512">(Jan 07 2019 at 23:59)</a>:</h4>
<p>this might be fixable, I'll think about it tomorrow</p>



<a name="154611751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154611751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154611751">(Jan 08 2019 at 00:04)</a>:</h4>
<p>well, the proposal overall looks complicated, and complicated things are often wrong (but also sometimes they are not, like the proof of Fermat's last theorem to continue on this metaphor lol)</p>



<a name="154611770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154611770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154611770">(Jan 08 2019 at 00:04)</a>:</h4>
<p>If we didn't allow any implied bounds on <code>dyn Foo&lt;T&gt;</code> other than super-trait bounds from <code>trait Foo&lt;T&gt;</code>, I might have a simpler proposal</p>



<a name="154629998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154629998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154629998">(Jan 08 2019 at 08:08)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I don’t know how to go the other way, i.e. if you have <code>trait Foo: Bar</code>, how to show that <code>dyn Foo: Bar</code> so eventually I think my proposal won’t work</p>



<a name="154630017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154630017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154630017">(Jan 08 2019 at 08:09)</a>:</h4>
<p>But I think the general idea about the soundness issue is right: bounds involving <code>Self</code> outside of outlive requirements must be true, every other must be proven</p>



<a name="154631402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154631402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154631402">(Jan 08 2019 at 08:47)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> ok I know why the proposal was looking complicated, I was trying to account for bounds like:<br>
<code>trait Foo&lt;T&gt;: Bar&lt;Self, T&gt;</code><br>
but traits with these bounds <em>cannot</em> be made into a trait object</p>



<a name="154631434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154631434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154631434">(Jan 08 2019 at 08:48)</a>:</h4>
<p>That becomes simpler then</p>



<a name="154631600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154631600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154631600">(Jan 08 2019 at 08:51)</a>:</h4>
<p>Let’s take again:</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">WC1</span><span class="p">,</span><span class="w"> </span><span class="p">...,</span><span class="w"> </span><span class="n">WCn</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</pre></div>


<p>Define <code>Shallow(?Self: Foo&lt;?T&gt;) :- MaybeShallow(WC1), ..., MaybeShallow(WCn)</code> where again <code>MaybeShallow(WC)</code> is syntactic sugar for:</p>
<ul>
<li><code>Shallow(WC)</code> for bounds of the form <code>WC == Self: Trait</code></li>
<li><code>WC</code> for other bounds (including outlive requirements)</li>
</ul>



<a name="154631647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154631647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154631647">(Jan 08 2019 at 08:52)</a>:</h4>
<p>(<code>Shallow</code> is inductive, I don’t think it needs to be co-inductive)</p>



<a name="154631871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154631871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154631871">(Jan 08 2019 at 08:59)</a>:</h4>
<p>Define: <code>WF(dyn Foo&lt;T&gt;) :- Shallow(dyn Foo&lt;T&gt;: Foo&lt;T&gt;)</code></p>



<a name="154631891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154631891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154631891">(Jan 08 2019 at 08:59)</a>:</h4>
<p><code>FromEnv(dyn Foo&lt;T&gt;: Foo&lt;T&gt;) :- FromEnv(dyn Foo&lt;T&gt;)</code></p>



<a name="154632099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154632099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154632099">(Jan 08 2019 at 09:04)</a>:</h4>
<p>And finally for all super-trait bound <code>SuperTrait&lt;...&gt;</code> transitively derived from <code>trait Foo&lt;T&gt;</code>, you have a generated impl:<br>
<code>Implemented(dyn Foo&lt;T&gt;: SuperTrait&lt;...&gt;)</code></p>



<a name="154632196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154632196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154632196">(Jan 08 2019 at 09:07)</a>:</h4>
<p>(The set of all super-trait bounds is easily computed, but this must be done outside of the logic)</p>



<a name="154672221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154672221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154672221">(Jan 08 2019 at 20:00)</a>:</h4>
<p>argh I did not get time to read this yet <span class="user-mention" data-user-id="131694">@scalexm</span>, hopefully later today</p>



<a name="154672351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154672351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154672351">(Jan 08 2019 at 20:01)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> no problem, I'm currently writing a prototype in chalk, I'll try to open a WIP PR this evening so that you might want to read that instead of the long and confuse thoughts I wrote in this stream</p>



<a name="154681955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154681955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154681955">(Jan 08 2019 at 22:16)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> see <a href="https://github.com/rust-lang-nursery/chalk/pull/200" target="_blank" title="https://github.com/rust-lang-nursery/chalk/pull/200">https://github.com/rust-lang-nursery/chalk/pull/200</a> for a very sketchy proof of concept</p>



<a name="154725351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725351">(Jan 09 2019 at 14:04)</a>:</h4>
<p>Hmm, implied bounds do add an extra wrinkle <span class="user-mention" data-user-id="131694">@scalexm</span></p>



<a name="154725369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725369">(Jan 09 2019 at 14:04)</a>:</h4>
<p>one thing that may be relevant is that <code>trait Foo&lt;T&gt; where T: Blah&lt;Self&gt;</code> is not a dyn-safe trait (because of the <code>Self</code> in the where-clauses)</p>



<a name="154725399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725399">(Jan 09 2019 at 14:05)</a>:</h4>
<p>Yes, that’s what I overlooked at the beginning</p>



<a name="154725420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725420">(Jan 09 2019 at 14:05)</a>:</h4>
<p>Without those kind of bounds my proposal is simpler <em>and</em> works</p>



<a name="154725425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725425">(Jan 09 2019 at 14:05)</a>:</h4>
<p>oh I see</p>



<a name="154725427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725427">(Jan 09 2019 at 14:05)</a>:</h4>
<p>I didn't quite get to the end yet :)</p>



<a name="154725507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725507">(Jan 09 2019 at 14:06)</a>:</h4>
<p>you are referring to <a href="#narrow/stream/144729-wg-traits/topic/scalexm's.20trait.20object.20thoughts/near/154631434" title="#narrow/stream/144729-wg-traits/topic/scalexm's.20trait.20object.20thoughts/near/154631434">this variant</a>, I guess — beginning at 3:51am</p>



<a name="154725575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725575">(Jan 09 2019 at 14:07)</a>:</h4>
<p>Mmh could you quote said variant, the link does not work on my phone</p>



<a name="154725650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725650">(Jan 09 2019 at 14:08)</a>:</h4>
<p>it's a lot of messages so hard to quote</p>



<a name="154725662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725662">(Jan 09 2019 at 14:08)</a>:</h4>
<blockquote>
<p>Let’s take again:</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">WC1</span><span class="p">,</span><span class="w"> </span><span class="p">...,</span><span class="w"> </span><span class="n">WCn</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</pre></div>


<p>Define <code>Shallow(?Self: Foo&lt;?T&gt;) :- MaybeShallow(WC1), ..., MaybeShallow(WCn)</code> where again <code>MaybeShallow(WC)</code> is syntactic sugar for:<br>
* <code>Shallow(WC)</code> for bounds of the form <code>WC == Self: Trait</code><br>
* <code>WC</code> for other bounds (including outlive requirements)</p>
</blockquote>



<a name="154725672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725672">(Jan 09 2019 at 14:08)</a>:</h4>
<p>Right :)</p>



<a name="154725673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725673">(Jan 09 2019 at 14:08)</a>:</h4>
<blockquote>
<p>(<code>Shallow</code> is inductive, I don’t think it needs to be co-inductive)</p>
</blockquote>



<a name="154725675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725675">(Jan 09 2019 at 14:09)</a>:</h4>
<p>etc</p>



<a name="154725783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725783">(Jan 09 2019 at 14:10)</a>:</h4>
<p>one other thing to keep in mind is that we want to support <code>dyn (Foo+Bar)</code></p>



<a name="154725806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725806">(Jan 09 2019 at 14:10)</a>:</h4>
<p>Yes, I think the proposal does support them (my chalk PR implements multi-trait objects actually)</p>



<a name="154725835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725835">(Jan 09 2019 at 14:11)</a>:</h4>
<p>I'll have to read the PR</p>



<a name="154725864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154725864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154725864">(Jan 09 2019 at 14:11)</a>:</h4>
<p>With the above notations you have <code>WF(dyn Foo+Bar) :- Shallow(dyn (Foo+Bar): Foo), ObjectSafe(Foo), Shallow(dyn (Foo+Bar): Bar), ObjectSafe(Bar)</code></p>



<a name="154727315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154727315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154727315">(Jan 09 2019 at 14:30)</a>:</h4>
<p>ok I skimmed the PR</p>



<a name="154727355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154727355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154727355">(Jan 09 2019 at 14:31)</a>:</h4>
<p>I still have to wrap my head around the <code>Shallow</code> concept somehow</p>



<a name="154727458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154727458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154727458">(Jan 09 2019 at 14:32)</a>:</h4>
<p>I guess the point is that <code>Shallow</code> gives you the (transitive) non-supertrait where clauses</p>



<a name="154730509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154730509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154730509">(Jan 09 2019 at 15:10)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> exactly, + the outlive requirements</p>



<a name="154730519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154730519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154730519">(Jan 09 2019 at 15:10)</a>:</h4>
<p>(Although they are not modeled in chalk)</p>



<a name="154730528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154730528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154730528">(Jan 09 2019 at 15:10)</a>:</h4>
<p><code>Shallow</code> is probably not a good name btw</p>



<a name="154730688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154730688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154730688">(Jan 09 2019 at 15:13)</a>:</h4>
<p>But the idea behind <code>Shallow</code> is summarized by these two messages:</p>



<a name="154730705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154730705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154730705">(Jan 09 2019 at 15:13)</a>:</h4>
<p>« so the idea is that, when you have a trait object say <code>dyn Foo&lt;T&gt;</code>, the things we are afraid of are what we can deduce about <code>T</code> »</p>



<a name="154730716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154730716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154730716">(Jan 09 2019 at 15:13)</a>:</h4>
<p>« the things we can deduce about <code>T</code> are basically:</p>
<ul>
<li>all the explicit bounds mentioning <code>T</code> that we can found on the <code>trait Foo&lt;T&gt; where ...</code> declaration</li>
<li>all the implicit outlive bounds on <code>T</code> than we can syntactically derive from outlive requirements on <code>Self</code> than can be found on the <code>trait Foo&lt;T&gt; where ...</code> declaration »</li>
</ul>



<a name="154759876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154759876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154759876">(Jan 09 2019 at 21:39)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I think we may not even need <code>Shallow</code> if we write the <code>impl SuperTrait for dyn Trait</code> cleverly (i.e. with the right where clauses)</p>



<a name="154759884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/scalexm%27s%20trait%20object%20thoughts/near/154759884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/scalexm&#x27;s.20trait.20object.20thoughts.html#154759884">(Jan 09 2019 at 21:39)</a>:</h4>
<p>I'll try this week-end</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>